import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:verse_systems/commom/models/question_model.dart';
import 'package:verse_systems/pages/mine/mine_control.dart';
import 'package:verse_systems/res/colors.dart';
import 'package:verse_systems/utils/image_utils.dart';
import 'package:verse_systems/widgets/drawer_appbar.dart';

class MieQuestion extends StatefulWidget {
  const MieQuestion({super.key});

  @override
  State<MieQuestion> createState() => _MieQuestionState();
}

class _MieQuestionState extends State<MieQuestion> {
  final control = Get.find<MineControl>();
  final state = Get.find<MineControl>().state;

  @override
  void initState() {
    super.initState();
    control.getQuestion();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar:  DrawerAppbar(
          title: "questions".tr,
        ),
        body: GetBuilder<MineControl>(
            init: control,
            builder: (_) {
              return SingleChildScrollView(
                child:ExpansionPanelList(
                    elevation: 0,
                    dividerColor: Colors.white,
                    children: state.tasksVoList.map((QuestionModel category) {
                      return ExpansionPanel(
                        canTapOnHeader: true,
                        headerBuilder: (context, isExpanded) {
                          return ListTile(
                              leading: Image.asset(
                                ImageUtils.getImgPath("question_icon"),
                                fit: BoxFit.fill,
                                width: 20.w,
                                height: 25.w,
                              ),
                              title: Text(category.title.toString()));
                        },
                        body: Container(
                          padding: EdgeInsets.symmetric(horizontal: 20.w),
                          margin: EdgeInsets.symmetric(vertical: 5.w),
                          child: Text(
                            category.content.toString(),
                            style: TextStyle(
                                fontSize: 12.sp,
                                color: Colours.app_sendcode_color,
                                height: 1.5),
                          ),
                        ),
                        isExpanded: category.isExpand,
                      );
                    }).toList(),
                    expansionCallback: control.updateRefresh,
                  ));
            }));
  }
}
